Repository navigation
Return Status::Failure from HDF5IO::open instead of throwing - #363
Merged
Merged
Conversation
HDF5IO::open let H5::Exception escape if HDF5 couldn't open or create the file (e.g., a file that is not an HDF5 file, or a directory that does not exist or is not writable), and threw std::invalid_argument for an invalid file mode. HDF5 exceptions do not derive from std::exception, so callers that check the returned status did not catch them. Catch them, print the HDF5 error, and return Status::Failure. openS3 and openRemote already caught the exception of the file open, but returned without a message. They now print the HDF5 error too. In all three functions, the creation of the file access property list (which can throw too) is inside the try block. open uses the non-throwing overload of std::filesystem::exists. Fixes #362 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
oruebel
commented
Nov 4, 2026
oruebel
marked this pull request as ready for review
November 4, 2026 08:22
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #363 +/- ##
==========================================
+ Coverage 84.69% 84.71% +0.02%
==========================================
Files 71 71
Lines 4651 4664 +13
Branches 668 668
==========================================
+ Hits 3939 3951 +12
- Misses 712 713 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
oruebel
commented
Nov 4, 2026
oruebel
left a comment
Contributor
Author
There was a problem hiding this comment.
Reviewed. Looks good
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #362
Motivation
HDF5IO::openreturns aStatus, but letH5::Exceptionescape if HDF5 couldn't open or create the file, e.g., for a file that is not an HDF5 file or a directory that does not exist or is not writable. HDF5 C++ exceptions do not derive fromstd::exception, so callers that check the returned status (and catchstd::exception) did not catch them. In the Open Ephys NWB Format plugin, this terminated the GUI (open-ephys-plugins/nwb-format#6 catchesH5::Exceptionas a workaround).Changes
HDF5IO::open(FileMode, const ChunkCacheConfig&)catchesH5::Exceptionwhen opening or creating the file, prints the HDF5 error tostd::cerr, and returnsStatus::Failure, asopenS3,openRemote, andclosealready do.Status::Failureinstead of throwingstd::invalid_argument.HDF5IO::openS3andHDF5IO::openRemotealready caught the exception of the file open, but returnedStatus::Failurewithout a message. They now print the HDF5 error too, and a message if the driver can't be set.tryblock, sinceH5::FileAccPropListcan throw too.openuses the non-throwing overload ofstd::filesystem::exists, which otherwise throwsstd::filesystem::filesystem_error, e.g., if a directory of the path is not accessible.open,openS3, andopenRemote.openS3andopenRemote.Testing
-DAQNWB_USE_REMFILE=ON, as in CI; all 143 tests pass, including the ROS3 and remfile tests.🤖 Generated with Claude Code